/*
 *  作业2
 */
package com.stage_2.module_1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class PrepareStatementTest {

    public static void main(String[] args) throws Exception{

        String url = "jdbc:mysql://localhost:3306/db1?characterEncoding=utf8";
        String use = "root";
        String password = "tyd000312";
        Connection con = DriverManager.getConnection( url, use, password);

        Statement statement = con.createStatement();

        String sql1 = "select * from employee WHERE name LIKE '李%'";

        ResultSet resultSet1 = statement.executeQuery(sql1);
        System.out.println(sql1);
        while(resultSet1.next()){
            int id = resultSet1.getInt("id");
            String name = resultSet1.getString("name");
            System.out.println(id + " + " + name );
        }

        System.out.println("_____________________________________________________________");

        String sql2 = "select * from employee WHERE gender = '男'";
        System.out.println(sql2);
        ResultSet resultSet2 = statement.executeQuery(sql2);

        while(resultSet2.next()){
            int id = resultSet2.getInt("id");
            String name = resultSet2.getString("name");
            System.out.println(id + " + " + name );
        }

        resultSet1.close();
        resultSet2.close();
        statement.close();
        con.close();

    }

}
